namespace learn
{

    public class FileLogger
    {
        private readonly string logPath;
        public FileLogger(string logPath)
        {
            this.logPath = logPath;
            Logger.WriteMessage += LogMessage;
        }

        public void DetachLog()
        {
            Logger.WriteMessage -= LogMessage;
        }

        private void LogMessage(string message)
        {

            try
            {
                using (var log = File.AppendText(logPath))
                {
                    log.WriteLine(message);
                    log.Flush();
                }

            }
            catch (Exception ex) { }
        }
    }
}